package m.jclecai.com.adapter.holder;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import m.jclecai.com.R;

import butterknife.BindView;

/**
 * Created by ZD on 2017/5/16.
 */

public class GroupBuyInfoHolder extends ViewHolder {

    @BindView(R.id.list_item_parent_title)
    public TextView list_item_parent_title;
    @BindView(R.id.tv_tag)
    public TextView tv_tag;
    @BindView(R.id.list_item_parent_icon)
    public ImageView list_item_parent_icon;
    @BindView(R.id.iv_drive)
    public View iv_drive;

    public GroupBuyInfoHolder(Context context, @LayoutRes int resource) {
        super(context, resource);
    }

    public void init(int groupPosition,String teambuy_isshow,
                     String fllowPeople,boolean isExpanded,String term){
        if(groupPosition == 0) {
            list_item_parent_title.setText("投注信息");
            tv_tag.setText(teambuy_isshow);
            tv_tag.setTextColor(ContextCompat.getColor(getContext(),R.color.login_txt));
        }else {
            if(!TextUtils.isEmpty(term)){
                String str[] = term.split(",");
                list_item_parent_title.setText(str[0]);
                tv_tag.setText(str[1]);
            }else {
                list_item_parent_title.setText("跟单人数");
                tv_tag.setText(fllowPeople);
            }
            tv_tag.setTextColor(ContextCompat.getColor(getContext(),R.color.a));
        }
        iv_drive.setVisibility(View.VISIBLE);
        if(!isExpanded){
            list_item_parent_icon.setImageResource(R.drawable.cz);
        }else {
            list_item_parent_icon.setImageResource(R.drawable.d0);
        }
    }
}
